package com.shirley.pers.zhufengfmvi.entities;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Description: 发现模块，推荐部分 抽象的，实体类，定义这个类，就是为让ListView能够显示不同数据格式的布局，实际的数据结构，需要继承这个类<br/>
 * <p/>
 * Copyright (c) , 2016, Shirley Xian <br/>
 * This program is protected by copyright laws. <br/>
 * ClassName: DiscoveryRecommendItem<br/>
 * Date: 2016/4/6 16:44
 *
 * @author Shirley Xian
 * @version 1.0
 */
public class DiscoveryRecommendItem {
    public static final int TYPE_FOCUS_IMAGE = 0;
    public static final int TYPE_DISCOVERY_COLUMNS = 1;
    public static final int TYPE_EDITE_HOT_RECOMMEND = 2;
    public static final int TYPE_SPECIAL_COMLUMNS = 3;

    private String title;
    private boolean hasMore;

    public void parseJson(JSONObject json) throws JSONException {
        if (json != null) {
            title = json.getString("title");
            hasMore = json.optBoolean("hasMore", false);
        }
    }

    /**
     * 获取类型数目
     *
     * @return
     */
    public static int getViewTypeCount() {
        return 4;
    }

    /**
     * 获取item的类型
     *
     * @return
     */
    public int getItemViewType() {
        int mType = -1;
        if (this instanceof RecommendAlbums) {
            mType = TYPE_EDITE_HOT_RECOMMEND;
        } else if (this instanceof HighQualityListenList) {
            mType = TYPE_SPECIAL_COMLUMNS;
        } else if (this instanceof DiscoveryColumnsList) {
            mType = TYPE_DISCOVERY_COLUMNS;
        }
        return mType;
    }

    public String getTitle() {
        return title;
    }

    public boolean isHasMore() {
        return hasMore;
    }
}
